export default {
	methods: {
		// 验证是否已连接设备
		checkConnected(showTip = true) {
			const deviceId = uni.getStorageSync('deviceId')
			if (!deviceId) {
				showTip && uni.showToast({
					title: '设备未连接',
					icon: 'error'
				});
				return null;
			}
			return deviceId;
		},
		// 同步已连接状态
		syncConnectedStatus() {
			const deviceId = uni.getStorageSync('deviceId');
			this.$store.state.device.scanneds.forEach(d => {
				if (d.id === deviceId) {
					d.status = 1;
				} else {
					d.status = 0;
				}
			});
		}
	}
}
